#!/usr/bin/env node

const http  = require('http'),
      fs=require('fs');
const html=fs.readFileSync('./index.html');
const value=fs.readFileSync('./content.txt');

http.createServer((req,res)=>{
  if(req.url==='/'){
    //加载html页面
    res.writeHead(200,{
      'Content-Type':'text/html',
      'Content-Length':Buffer.byteLength(html)
    });
    res.end(html);
  }
  if(req.url==='/getlist'){
    //将爬虫得到的数据返回给index.html
    res.end(value);
  }


}).listen(8080);
